//
//  AlterView.m
//  textTounity
//
//  Created by 齐凯 on 2018/5/25.
//  Copyright © 2018年 Mac. All rights reserved.
//

#import "AlterView.h"


@implementation AlterView
{
    NSString *str;
}

static AlterView *alert = nil;


+ (AlterView *) instance{
    
    if (alert==nil)
    {
        alert=[[AlterView alloc]init];
        
    }
    return alert;
}

#if defined(__cplusplus)
extern"C"{
#endif
    
    void _showTestView(char *msg){
        
        
        [AlterView instance];
        
        NSString * stringMsg = [NSString stringWithUTF8String:msg];
        
        [alert showTestView:stringMsg];
        
    }
    
    void _showCompressView (void){
        
        [AlterView instance];
        
        [alert showCompress];
        
    }
    
#if defined(__cplusplus)
}
#endif



- (void)showCompress{
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    
    UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, window.frame.size.width - 150, 50)];
    lab.text = @"实现showCompress方法";
    lab.textAlignment = 1;
    lab.center = CGPointMake(window.frame.size.width / 2 , window.frame.size.height - 40);
    [lab setFont:[UIFont systemFontOfSize:20]];
    lab.textColor = [UIColor whiteColor];
    lab.numberOfLines = 0;
    lab.backgroundColor = [UIColor lightGrayColor];
    lab.alpha = 0.7;
    lab.layer.masksToBounds = YES;
    lab.layer.cornerRadius = 10;
    
    [window addSubview:lab];
    
}
- (void)showTestView:(NSString *)msg{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
    [alert show];
    str = msg;
    NSLog(@"----------------------------------------%@",str);
    //这是将iOS的字符串传递到unity中的方法
    /*
     参数一 unity中的代码所挂载的物体
     参数二 unity中代码里面的方法
     参数三 所需传递的字符串
     */
    UnitySendMessage([@"Main Camera" UTF8String],[@"iOS" UTF8String],[@"hello world" UTF8String]);
}


@end






